﻿<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
  
  <head>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-39155502-5"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
  
      gtag('config', 'UA-39155502-5');
    </script>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Class DataStreamer
   | MongoDB.Entities </title>
    <meta name="viewport" content="width=device-width">
    <meta name="title" content="Class DataStreamer
   | MongoDB.Entities ">
    <meta name="generator" content="docfx 2.58.4.0">
    <meta name="description" content="A data access library for MongoDB with an elegant api, LINQ support and built-in entity relationship management.">
    <link rel="shortcut icon" href="../images/favicon.ico">
    <link rel="stylesheet" href="../styles/docfx.vendor.css">
    <link rel="stylesheet" href="../styles/docfx.css">
    <link rel="stylesheet" href="../styles/main.css">
    <meta property="docfx:navrel" content="../toc.html">
    <meta property="docfx:tocrel" content="toc.html">
    
    <meta property="docfx:rel" content="../">
    <meta property="docfx:newtab" content="true">
    <meta property="og:title" content="MongoDB.Entities">
    <meta property="og:site_name" content="MongoDB.Entities">
    <meta property="og:url" content="https://mongodb-entities.com">
    <meta property="og:description" content="A data access library for MongoDB with an elegant api, LINQ support and built-in entity relationship management,">
    <meta property="og:type" content="website">
    <meta property="og:image" content="https://mongodb-entities.com/images/social-square.png">  
  </head>
  <body data-spy="scroll" data-target="#affix" data-offset="120">
    <div id="wrapper">
      <header>
        
        <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
          <div class="container">
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              
              <a class="navbar-brand" href="../index.html">
                <img id="logo" class="svg" src="../images/icon.png" alt="">
              </a>
            </div>
            <div class="collapse navbar-collapse" id="navbar">
              <form class="navbar-form navbar-right" role="search" id="search">
                <div class="form-group">
                  <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
                </div>
              </form>
            </div>
          </div>
        </nav>
        
        <div class="subnav navbar navbar-default">
          <div class="container hide-when-search" id="breadcrumb">
            <ul class="breadcrumb">
              <li></li>
            </ul>
          </div>
        </div>
      </header>
      <div class="container body-content">
        
        <div id="search-results">
          <div class="search-list">Search Results for <span></span></div>
          <div class="sr-items">
            <p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
          </div>
          <ul id="pagination" data-first="First" data-prev="Previous" data-next="Next" data-last="Last"></ul>
        </div>
      </div>
      <div role="main" class="container body-content hide-when-search">
        
        <div class="sidenav hide-when-search">
          <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
          <div class="sidetoggle collapse" id="sidetoggle">
            <div id="sidetoc"></div>
          </div>
        </div>
        <div class="article row grid-right">
          <div class="col-md-10">
            <article class="content wrap" id="_content" data-uid="MongoDB.Entities.DataStreamer">
  
  
  <h1 id="MongoDB_Entities_DataStreamer" data-uid="MongoDB.Entities.DataStreamer" class="text-break">Class DataStreamer
  </h1>
  <div class="markdown level0 summary"><p>Provides the interface for uploading and downloading data chunks for file entities.</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><span class="xref">System.Object</span></div>
    <div class="level1"><span class="xref">DataStreamer</span></div>
  </div>
  <div class="inheritedMembers">
    <h5>Inherited Members</h5>
    <div>
      <span class="xref">System.Object.Equals(System.Object)</span>
    </div>
    <div>
      <span class="xref">System.Object.Equals(System.Object, System.Object)</span>
    </div>
    <div>
      <span class="xref">System.Object.GetHashCode()</span>
    </div>
    <div>
      <span class="xref">System.Object.GetType()</span>
    </div>
    <div>
      <span class="xref">System.Object.MemberwiseClone()</span>
    </div>
    <div>
      <span class="xref">System.Object.ReferenceEquals(System.Object, System.Object)</span>
    </div>
    <div>
      <span class="xref">System.Object.ToString()</span>
    </div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="MongoDB.Entities.html">MongoDB.Entities</a></h6>
  <h6><strong>Assembly</strong>: MongoDB.Entities.dll</h6>
  <h5 id="MongoDB_Entities_DataStreamer_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class DataStreamer</code></pre>
  </div>
  <h3 id="methods">Methods
  </h3>
  
  
  <a id="MongoDB_Entities_DataStreamer_DeleteBinaryChunks_" data-uid="MongoDB.Entities.DataStreamer.DeleteBinaryChunks*"></a>
  <h4 id="MongoDB_Entities_DataStreamer_DeleteBinaryChunks_MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DataStreamer.DeleteBinaryChunks(MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">DeleteBinaryChunks(IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Deletes only the binary chunks stored in the database for this file entity.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public Task DeleteBinaryChunks(IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DataStreamer_DownloadAsync_" data-uid="MongoDB.Entities.DataStreamer.DownloadAsync*"></a>
  <h4 id="MongoDB_Entities_DataStreamer_DownloadAsync_System_IO_Stream_System_Int32_System_Threading_CancellationToken_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DataStreamer.DownloadAsync(System.IO.Stream,System.Int32,System.Threading.CancellationToken,MongoDB.Driver.IClientSessionHandle)">DownloadAsync(Stream, Int32, CancellationToken, IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Download binary data for this file entity from mongodb in chunks into a given stream.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public async Task DownloadAsync(Stream stream, int batchSize = 1, CancellationToken cancellation = default(CancellationToken), IClientSessionHandle session = null)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.IO.Stream</span></td>
        <td><span class="parametername">stream</span></td>
        <td><p>The output stream to write the data</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Int32</span></td>
        <td><span class="parametername">batchSize</span></td>
        <td><p>The number of chunks you want returned at once</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DataStreamer_DownloadWithTimeoutAsync_" data-uid="MongoDB.Entities.DataStreamer.DownloadWithTimeoutAsync*"></a>
  <h4 id="MongoDB_Entities_DataStreamer_DownloadWithTimeoutAsync_System_IO_Stream_System_Int32_System_Int32_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DataStreamer.DownloadWithTimeoutAsync(System.IO.Stream,System.Int32,System.Int32,MongoDB.Driver.IClientSessionHandle)">DownloadWithTimeoutAsync(Stream, Int32, Int32, IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Download binary data for this file entity from mongodb in chunks into a given stream with a timeout period.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public Task DownloadWithTimeoutAsync(Stream stream, int timeOutSeconds, int batchSize = 1, IClientSessionHandle session = null)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.IO.Stream</span></td>
        <td><span class="parametername">stream</span></td>
        <td><p>The output stream to write the data</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Int32</span></td>
        <td><span class="parametername">timeOutSeconds</span></td>
        <td><p>The maximum number of seconds allowed for the operation to complete</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Int32</span></td>
        <td><span class="parametername">batchSize</span></td>
        <td></td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DataStreamer_UploadAsync_" data-uid="MongoDB.Entities.DataStreamer.UploadAsync*"></a>
  <h4 id="MongoDB_Entities_DataStreamer_UploadAsync_System_IO_Stream_System_Int32_System_Threading_CancellationToken_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DataStreamer.UploadAsync(System.IO.Stream,System.Int32,System.Threading.CancellationToken,MongoDB.Driver.IClientSessionHandle)">UploadAsync(Stream, Int32, CancellationToken, IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Upload binary data for this file entity into mongodb in chunks from a given stream.</p>
<p>TIP: Make sure to save the entity before calling this method.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public async Task UploadAsync(Stream stream, int chunkSizeKB = 256, CancellationToken cancellation = default(CancellationToken), IClientSessionHandle session = null)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.IO.Stream</span></td>
        <td><span class="parametername">stream</span></td>
        <td><p>The input stream to read the data from</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Int32</span></td>
        <td><span class="parametername">chunkSizeKB</span></td>
        <td><p>The 'average' size of one chunk in KiloBytes</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DataStreamer_UploadWithTimeoutAsync_" data-uid="MongoDB.Entities.DataStreamer.UploadWithTimeoutAsync*"></a>
  <h4 id="MongoDB_Entities_DataStreamer_UploadWithTimeoutAsync_System_IO_Stream_System_Int32_System_Int32_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DataStreamer.UploadWithTimeoutAsync(System.IO.Stream,System.Int32,System.Int32,MongoDB.Driver.IClientSessionHandle)">UploadWithTimeoutAsync(Stream, Int32, Int32, IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Upload binary data for this file entity into mongodb in chunks from a given stream with a timeout period.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public Task UploadWithTimeoutAsync(Stream stream, int timeOutSeconds, int chunkSizeKB = 256, IClientSessionHandle session = null)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.IO.Stream</span></td>
        <td><span class="parametername">stream</span></td>
        <td><p>The input stream to read the data from</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Int32</span></td>
        <td><span class="parametername">timeOutSeconds</span></td>
        <td><p>The maximum number of seconds allowed for the operation to complete</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Int32</span></td>
        <td><span class="parametername">chunkSizeKB</span></td>
        <td><p>The 'average' size of one chunk in KiloBytes</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
</article>
          </div>
          
          <div class="hidden-sm col-md-2" role="complementary">
            <div class="sideaffix">
              <div class="contribution">
                <ul class="nav">
                </ul>
              </div>
              <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
                <h5>In This Article</h5>
                <div></div>
              </nav>
            </div>
          </div>
        </div>
      </div>
      
      <footer>
        <div class="grad-bottom"></div>
        <div class="footer">
          <div class="container">
            <span class="pull-right">
              <a href="#top">Back to top</a>
            </span>
            Developed by <a href='https://github.com/dj-nitehawk'>Đĵ ΝιΓΞΗΛψΚ</a> and <a href='https://github.com/dj-nitehawk/MongoDB.Entities/graphs/contributors'>contributors</a> / Licensed under <a href='https://github.com/dj-nitehawk/MongoDB.Entities/blob/master/LICENSE'>MIT</a> / Website generated by <a href='https://dotnet.github.io/docfx/'>DocFX</a>
            
          </div>
        </div>
      </footer>
    </div>
    
    <script type="text/javascript" src="../styles/docfx.vendor.js"></script>
    <script type="text/javascript" src="../styles/docfx.js"></script>
    <script type="text/javascript" src="../styles/main.js"></script>
  </body>
</html>
